/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
//
*/

#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_DECODER)

#include <trace_log.h>
#include "umc_avs_dec_decompressor_fld.h"
#include "umc_avs_picture_header.h"
#include "umc_avs_mb_info.h"

namespace UMC
{

void AVSDecompressorField::CreateSymmetricalMotionVector(Ipp32s blockNum)
{
    AVSMVector mvFw;
    Ipp32u refIdxFw, refIdxBw;
    Ipp32s DistanceMul;

    // calculate vector distance
    refIdxFw = m_pMbInfo->refIdx[AVS_FORWARD][blockNum];
    refIdxBw = refIdxFw ^ 1;
    m_pMbInfo->refIdx[AVS_BACKWARD][blockNum] = (Ipp8u) refIdxBw;
    DistanceMul = m_blockDist[AVS_BACKWARD][refIdxBw] * (512 / m_blockDist[AVS_FORWARD][refIdxFw]);

    // compute the vector
    mvFw = m_pMbInfo->mv[AVS_FORWARD][blockNum];
    m_mvPred.vector.x = (Ipp16s) -((mvFw.vector.x * DistanceMul + 256) >> 9);
    m_mvPred.vector.y = (Ipp16s) -((mvFw.vector.y * DistanceMul + 256) >> 9);

} // void AVSDecompressorField::CreateSymmetricalMotionVector(Ipp32s blockNum)

} // namespace UMC

#endif // defined(UMC_ENABLE_AVS_VIDEO_DECODER)
